/**
 * 用户 API 接口
 * 统一封装用户相关的 API 调用
 */

import type { LoginForm, LoginResponse, User, UserForm, UserQuery, ApiResponse, ListResponse } from '@/types'
import {
  mockLogin,
  mockGetUserList,
  mockAddUser,
  mockUpdateUser,
  mockDeleteUser,
  mockBatchDeleteUser,
  mockGetUserDetail,
} from './mock'

/**
 * 用户登录
 */
export function login(data: LoginForm): Promise<ApiResponse<LoginResponse>> {
  return mockLogin(data)
}

/**
 * 获取用户列表
 */
export function getUserList(params: UserQuery): Promise<ApiResponse<ListResponse<User>>> {
  return mockGetUserList(params)
}

/**
 * 添加用户
 */
export function addUser(data: UserForm): Promise<ApiResponse<User>> {
  return mockAddUser(data)
}

/**
 * 更新用户
 */
export function updateUser(id: number, data: UserForm): Promise<ApiResponse<User>> {
  return mockUpdateUser(id, data)
}

/**
 * 删除用户
 */
export function deleteUser(id: number): Promise<ApiResponse<null>> {
  return mockDeleteUser(id)
}

/**
 * 批量删除用户
 */
export function batchDeleteUser(ids: number[]): Promise<ApiResponse<null>> {
  return mockBatchDeleteUser(ids)
}

/**
 * 获取用户详情
 */
export function getUserDetail(id: number): Promise<ApiResponse<User>> {
  return mockGetUserDetail(id)
}
